package vcp.gui.forms;

import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JLabel;
import javax.swing.border.TitledBorder;




import java.awt.Color;


import vcp.gui.components.VCPPanel;
import javax.swing.UIManager;


/**
 * Login Form
 *
 */
public class LoginForm extends VCPPanel{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JLabel lblLoginError;
	private JTextField textUsername;
	private JPasswordField txtPassword;
	private JButton btnLogin;
	
	/**
	 * Create the panel.
	 */
	public LoginForm() {
		Color cblue = Color.decode("#6B78B4");
		
		setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Log in", TitledBorder.LEADING, TitledBorder.TOP, null, Color.WHITE));
		setBackground(cblue);
		
		lblLoginError = new JLabel("");
		lblLoginError.setForeground(Color.RED);
		
		JLabel lblUname = new JLabel("Username");
		lblUname.setForeground(Color.WHITE);
		
		textUsername = new JTextField();
		textUsername.setColumns(10);
		
		JLabel lblPassword = new JLabel("Password");
		lblPassword.setForeground(Color.WHITE);
		
		txtPassword = new JPasswordField();
		txtPassword.setColumns(10);
		
		btnLogin = new JButton("login");

		btnLogin.setActionCommand("btnLogin");
		
		
		GroupLayout groupLayout = new GroupLayout(this);
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.TRAILING)
				.addGroup(groupLayout.createSequentialGroup()
					.addContainerGap()
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addGroup(groupLayout.createSequentialGroup()
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addComponent(lblUname)
								.addComponent(lblPassword))
							.addGap(33)
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addComponent(textUsername, GroupLayout.DEFAULT_SIZE, 323, Short.MAX_VALUE)
								.addComponent(txtPassword, GroupLayout.DEFAULT_SIZE, 323, Short.MAX_VALUE)))
						.addComponent(lblLoginError)
						.addComponent(btnLogin, Alignment.TRAILING))
					.addContainerGap())
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addComponent(lblLoginError)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblUname)
						.addComponent(textUsername, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(ComponentPlacement.UNRELATED)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblPassword)
						.addComponent(txtPassword, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(18)
					.addComponent(btnLogin)
					.addContainerGap(20, Short.MAX_VALUE))
		);
		setLayout(groupLayout);

	}

	

	public JTextField getTextUsername() {
		return textUsername;
	}

	public void setTextUsername(JTextField textUsername) {
		this.textUsername = textUsername;
	}

	public JPasswordField getTxtPassword() {
		return txtPassword;
	}

	public void setTxtPassword(JPasswordField txtPassword) {
		this.txtPassword = txtPassword;
	}

	public JButton getBtnLogin() {
		return btnLogin;
	}

	public void setBtnLogin(JButton btnLogin) {
		this.btnLogin = btnLogin;
	}
	
}






